﻿using System;
using System.Collections.Generic;
using Sklad1_2.Default;

namespace Sklad1_2.Add.Update
{
    public partial class UpdateFirma : Defaultform
    {
        public UpdateFirma()
        {
            InitializeComponent();
        }
        public UpdateFirma(List<string> item):base(item)
        {
            InitializeComponent();
            ABase.AddItem(comboBox1, "angar");
            ABase.AddItem(comboBox2, "category");
            comboBox1.SelectedValue = item[1];
            comboBox2.SelectedValue = item[2];
            textBox1.Text = item[3];

        }

        private void button2_Click(object sender, EventArgs e)
        {
            Close();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            string sklad = Convert.ToString(comboBox1.SelectedValue),
                   category = Convert.ToString(comboBox2.SelectedValue);
            if (textBox1.Text.Length > 0)
            {
                ABase.UpdateValueFirma(textBox1.Text, sklad, category, id);
                Close();
            }
        }

        private void comboBox1_SelectedValueChanged(object sender, EventArgs e)
        {
            Type t = typeof(Int32);
            if (comboBox1.SelectedValue.GetType() == t)
            {
                ABase.AddItemCategory(comboBox2, Convert.ToInt32(comboBox1.SelectedValue));
            }
        }
    }
}
